home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / basic / ace_final.lha / ACE_GPL_Release / prgs / Library / AppMenu.b next >
Encoding:
Text File  |  1996-08-29  |  1.9 KB  |  69 lines

  1. /*
  2. ** An example of AppMenus in ACE.
  3. ** Written by Nils Sjoholm, 6th October 1996.
  4. ** Modified by David Benn, 9th October 1996. 
  5. */
  6.  
  7. #include <exec/types.h>          /* Need this for the Amiga variable types */
  8. #include <workbench/workbench.h> /* This has DiskObject and AppIcon structs */
  9. #include <dos/dostags.h>
  10. #include <funcs/dos_funcs.h>
  11. #include <funcs/exec_funcs.h>    /* Exec message, port and library functions */
  12. #include <funcs/wb_funcs.h>      /* AppMenuItem function protos */
  13.  
  14. DECLARE STRUCT MsgPort   *myport : myport = NULL
  15. DECLARE STRUCT AppMenuItem *appitem0, *appitem1 : appitem0 = NULL : appitem1 = NULL
  16. DECLARE STRUCT AppMessage   *appmsg : appmsg = NULL
  17. BOOL success : success = FALSE
  18. LONGINT theType, theID
  19. STRING theCmd
  20.  
  21. LIBRARY exec
  22. LIBRARY workbench
  23.  
  24. myport = CreateMsgPort
  25. IF myport <> NULL THEN
  26.     appitem0 = AddAppMenuItemA(0&,~
  27.                               "Command 1",~
  28.                               "Browse Files",~
  29.                               myport,NULL)
  30.  
  31.     appitem1 = AddAppMenuItemA(1&,~
  32.                               "Command 2",~
  33.                               "Wash the dishes",~
  34.                               myport,NULL)
  35.  
  36.     IF appitem0 <> NULL And appitem1 <> NULL THEN
  37.         Print "Select Workbench Tools demo menuitem 'Browse Files'."
  38.         WaitPort(myport)
  39.  
  40.     Repeat
  41.       appmsg = GetMsg(myport)
  42.       If appmsg Then 
  43.         theType = appmsg->am_Type
  44.  
  45.         If theType = AMTYPE_APPMENUITEM Then 
  46.         theID = appmsg->am_ID 
  47.         theCmd = Cstr(appmsg->am_UserData)
  48.         End If
  49.  
  50.         ReplyMsg(appmsg)    /* should do this ASAP */
  51.  
  52.         If theType = AMTYPE_APPMENUITEM Then 
  53.         Print "AppMenuItem #";Str$(theID);
  54.         Print " - command = ";theCmd
  55.         End If
  56.       End If
  57.     Until appmsg = NULL
  58.  
  59.         success = RemoveAppMenuItem(appitem0)
  60.         If success Then Print "menuitem 0 removed."
  61.         success = RemoveAppMenuItem(appitem1)
  62.         If success Then Print "menuitem 1 removed."
  63.     END IF
  64.  
  65.     DeleteMsgPort(myport)
  66. END IF
  67.  
  68. LIBRARY CLOSE
  69.